home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 1 / csmp-v1-176.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  50.8 KB  |  1,394 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Mon, 05 Oct 92       Volume 1 : Issue 176
  2.  
  3. Today's Topics:
  4.  
  5.     Stymied++!  VBL Cursor Watching ideas?
  6.     Vertical Text drawing?
  7.     Spreadsheet like view
  8.     Loading Resources into MF Temp Mem.
  9.     updating finder windows
  10.     HOW IS QUICKBASIC FOR THE MAC?
  11.     Ah, but I am clever in how I patch, no?
  12.  
  13.  
  14.  
  15. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  16.  
  17. The digest is a collection of article threads from the internet newsgroup
  18. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  19. regularly and want an archive of the discussions.  If you don't know what a
  20. newsgroup is, you probably don't have access to it.  Ask your systems
  21. administrator(s) for details.  (This means you can't post questions to the
  22. digest.)
  23.  
  24. Each issue of the digest contains one or more sets of articles (called
  25. threads), with each set corresponding to a 'discussion' of a particular
  26. subject.  The articles are not edited; all articles included in this digest
  27. are in their original posted form (as received by our news server at
  28. cs.uoregon.edu).  Article threads are not added to the digest until the last
  29. article added to the thread is at least one month old (this is to ensure that
  30. the thread is dead before adding it to the digest).  Article threads that
  31. consist of only one message are generally not included in the digest.
  32.  
  33. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  34. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  35. file /pub/mac/csmp-digest/README before downloading any files.  The most
  36. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  37. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  38. archive has a mail server; send a message with the text '$MACarch help' (no
  39. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  40.  
  41. The digest is also available via email.  Just send a note saying that you
  42. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  43. automatically receive each new issue as it is created.  Sorry, back issues
  44. are not available through the mailing list.
  45.  
  46. Send administrative mail to mkelly@cs.uoregon.edu.
  47.  
  48.  
  49. -------------------------------------------------------
  50.  
  51. From: scott@mcl.ucsb.edu (Scott Bronson)
  52. Subject: Stymied++!  VBL Cursor Watching ideas?
  53. Date: 21 Jul 92 06:34:45 GMT
  54.  
  55. (The postincrement represents the minor cookie at the end of this letter.)
  56.  
  57. I've run into a real snag with my cursor-watching VBL idea (that I posted
  58. to the 'net a few days ago--it may be archived if the article has expired).
  59. Basically, I cannot see a good way to make my code future-compatible without
  60. taking an incredible performance hit.  Here are the ways that I have tried:
  61.  
  62. The first way I tried was the fastest.  I was getting upwards of 170 iterations
  63. per tick by PPosting() an event, checking the event's modifiers field that got
  64. filled in, then flushing it.  A lot of people frowned on this idea, so I tried
  65. a few other techniques.  Unfortunately, none performed better.
  66.  
  67. OSEventAvail and EventAvail are out.  I cannot get more than 48 iterations per
  68. tick using OSEventAvail, and EventAvail ended up somewhere around eight iters
  69. per tick.  Totally unacceptable if they are to be VBLs because they'd probably
  70. suck up more cycles than save.
  71.  
  72. GetKeys runs in great time.  I can get 127 iterations per tick using some
  73. cool key-watching code that I came up with.  Then I decided that I shouldn't
  74. just *assume* that GetKeys can be called from a VBL.  I was astounded that it
  75. can't!  Such a fast, low-level call that may move or purge memory?!?  Rats.
  76.  
  77. So, I'm stuck.  Here are my options as I see them now:
  78.  
  79. o Use my super-fast first idea of posting and always flushing the event, hoping
  80.   that because the event is always flushed and because the event gets posted
  81.   and removed by a VBL, the system will not be able to choke on it.
  82. o Use some slow code based on OSEventAvail that I have up and running, but can
  83.   only get 48 iterations per tick (on a IIci).
  84. o Patch some other trap (GNE?) so that I can use my sufficiently fast GetKeys
  85.   code.  Problem is, your traps get disabled when your app gets switched out.
  86. o Use some other solution that I haven't thought of yet (and you're going to
  87.   tell me :-).
  88.  
  89. I'd like to hear what you guys think would be best.  Right now I think I'll
  90. keep using the first code that I posted, but waking up my application with
  91. WakeUpProcess() rather than leaving the app1 event in the queue.  Am I
  92. overlooking something obvious?  Is it possible and future compatible to
  93. install a patch that will not be removed when my app switches out?
  94.  
  95. Pipe Dream: Obviously PPostEvent can get at the current state of the
  96. modifiers super-quick and at VBL time.  Is it possible for me to do the
  97. same?
  98.  
  99. Just doing my part to save precious machine cycles...
  100.  
  101.     - Scott
  102.  
  103.  
  104. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  105.  
  106. I thought it would be a real shame that my tuned key-watching code would
  107. go unused, so I'm hoping that someone else may find it useful.  If you do
  108. use it, all I ask is that you mail me a short letter telling me how.  I will
  109. support this code if you have any questions.  This code is now public domain.
  110.  
  111.     short gOldKeys = 0L; // Global var holding current state of modifiers
  112.  
  113.     Boolean ModifiersChanged( void )
  114.     {
  115.         KeyMap km;
  116.         register Boolean on = false;
  117.         asm {
  118.             PEA    km
  119.             GetKeys
  120.             MOVE.L    km[1],D1
  121.             ANDI.W    #0x800F,D1
  122.             CMP.W    gOldKeys,D1
  123.             BEQ.S    @exit
  124.             MOVE.W    D1,gOldKeys
  125.             MOVEQ    #1,on
  126.         @exit:
  127.         } return on;
  128.     }
  129.  
  130. +++++++++++++++++++++++++++
  131.  
  132. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  133. Date: 23 Jul 92 17:48:20 +1200
  134. Organization: University of Waikato, Hamilton, New Zealand
  135.  
  136. In article <scott.711700485@mcl>, scott@mcl.ucsb.edu (Scott Bronson) writes:
  137.  
  138. > I've run into a real snag with my cursor-watching VBL idea...
  139.  
  140. [different techniques described, with the fastest ones being the least
  141. "future-safe"]
  142.  
  143. > Pipe Dream: Obviously PPostEvent can get at the current state of the
  144. > modifiers super-quick and at VBL time.  Is it possible for me to do the
  145. > same?
  146.  
  147. Well, you could bite the bullet and peek at the low-memory area where the
  148. modifier flags are kept (which is obviously what PPostEvent is doing). And
  149. if your code is very successful and you make a lot of money from it, then
  150. you'll have the resources to bring out a new, slower version when it breaks
  151. under a future, faster machine. :-)
  152.  
  153. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  154. Computer Services Dept                     fax: +64-7-838-4066
  155. University of Waikato            electric mail: ldo@waikato.ac.nz
  156. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  157. PenWindows--the CP/M of pen computing?
  158.  
  159. ---------------------------
  160.  
  161. From: Steve Kohlmeyer
  162. Subject: Vertical Text drawing?
  163. Date: 22 Jul 92 18:32:54 GMT
  164. Organization: University of Minnesota
  165.  
  166. Hello Netters,
  167. Does anyone know an easy way to draw text vertically?  I want all of  
  168. the letters rotated as well as the whole word -- like the label on a graph.
  169.  
  170. Thanks for any replies!
  171. Steve Kohlmeyer
  172. steve@mind.psych.umn.edu
  173.  
  174.    
  175.  
  176. +++++++++++++++++++++++++++
  177.  
  178. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  179. Organization: Kalamazoo College
  180. Date: Wed, 22 Jul 1992 20:24:11 GMT
  181.  
  182. steve@mind.psych.umn.edu writes:
  183. >Does anyone know an easy way to draw text vertically?  I want all of  
  184. >the letters rotated as well as the whole word -- like the label on a graph.
  185.  
  186. If this isn't on the FAQ, it should be.
  187.  
  188. You can't do it directly.  Draw them into an offscreen bit/pixmap,
  189. rotate it, and CopyBits it to the screen.  QuickDraw GX, due out next
  190. year, will offer support for drawing rotated text.
  191. - -- 
  192.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  193.  He let the contents of the bottle do the thinking
  194.  Can't shake the devil's hand and say you're only kidding            - TMBG
  195.  
  196. ---------------------------
  197.  
  198. From: trimper@edsi.plexus.COM (Greg Trimper)
  199. Subject: Spreadsheet like view
  200. Date: 17 Jul 92 01:36:30 GMT
  201. Organization: Enterprise Data Systems Incorporated, Appleton WI
  202.  
  203. trimper@edsi.plexus.COM (Greg Trimper) writes:
  204.  
  205. >I am using Think C, and want to implement a spreadsheet-style view
  206. >for displaying and editing data.  
  207.  
  208. >The way I look at it, I have two options:
  209. >1) A dialog with lots of editText items, get each item as it is edited
  210.  
  211. >2) Draw a window with a TERect for EACH item, and handle data after TE is
  212. >done with it - atoi, for example.
  213.  
  214. >Is there a good and EASY way of doing this?  I really only need a
  215. >20x5 array of items - a little to big for a Dialog, but seems like it will
  216. >be a pain in a window with TextEdit
  217.  
  218.  
  219. Oh, and I should mention that I am trying to avoid the LIST manager, unless
  220. someone knows how to make it select multiple items in either row-row
  221. or column-column multiples.
  222.  
  223.  
  224. Greg Trimper   trimper@edsi.plexus.com  
  225.  
  226. +++++++++++++++++++++++++++
  227.  
  228. From: dent@DIALix.oz.au (Andrew Dent)
  229. Organization: DIALix Services, Perth, Western Australia
  230. Date: Sun, 19 Jul 92 01:48:27 GMT
  231.  
  232. The easiest way would be to use an off-the-shelf product called Matrix
  233. Engine, from DataPak software. (I haven't used this particular product but
  234. I'm very happy with everything else they've written).
  235.  
  236. Matrix Engine gives you
  237. - - an easier interface
  238. - - virtual memory for large lists
  239. - - gridline drawing
  240. - - simple arithmetic across columns
  241. - - nueric formattingm        
  242. - - hooks to change any behaviour         
  243. - - comprehensive memory debugger         
  244.  
  245. List price is $395 and they can be contacted on (800) 327 6703, (206) 573 9155
  246. or via CompuSere 76424, 3027   (Internet 76424.3027@compuserve.com).
  247.  
  248. Another approach would be to start using the Think Class Library - there's a 
  249. book coming out soon by a guy called Rich Parker which shows how to use TCL
  250. and AppMaker - based on building a spreadsheet!.
  251.  
  252. Andy Dent (A.D. Software - Mac & VAX programming)
  253. 94 Bermuda Dve, BALLAJURA  Western Australia  6066
  254. Phone/Fax: 09 249 2719 (local)  +619 249 2719 (International)
  255.        Internet: dent@DIALix.oz.au    Compuserve: 100033,3241
  256.  
  257.  
  258. +++++++++++++++++++++++++++
  259.  
  260. From: sbill@informix.com (Bill Stackhouse)
  261. Date: 20 Jul 92 18:09:15 GMT
  262. Organization: Informix Software, Inc.
  263.  
  264.  
  265. There is a product called StoneTable that is a Think C library
  266. that provides all the functions of the list manager plus:
  267.  
  268. variable size rows/columns
  269. row/column titles
  270. edit cells/titls in place
  271. each cell can be formatted differently (font, size, just, etc)
  272. user interface to allow resizing/move/copy/hide row/columns, scroll
  273.      text in single cell
  274. and more.
  275.  
  276. StoneTable is $150 from 
  277.    StoneTablet Publishing
  278.    P.O Box 12665
  279.    Portland, OR 97212-0665
  280.  
  281.    CompuServe 70303,2546
  282.    Internet 70303.2546@compuserve.com
  283.  
  284. They have a brochure on the product that can be requested from the 
  285. same address.
  286.  
  287. Just a happy user
  288. Bill Stackhouse
  289. sbill@informix.com
  290.  
  291. +++++++++++++++++++++++++++
  292.  
  293. From: rla20@duts.ccc.amdahl.com (Roger Allen)
  294. Date: 21 Jul 92 20:56:52 GMT
  295. Organization: Amdahl Corporation, Sunnyvale CA
  296.  
  297. In article <1992Jul17.013630.14805@edsi.plexus.COM> trimper@edsi.plexus.COM (Greg Trimper) writes:
  298. >trimper@edsi.plexus.COM (Greg Trimper) writes:
  299. >
  300. >>I am using Think C, and want to implement a spreadsheet-style view
  301. >>for displaying and editing data.  
  302. >
  303. >>The way I look at it, I have two options:
  304. >>1) A dialog with lots of editText items, get each item as it is edited
  305. >
  306. >>2) Draw a window with a TERect for EACH item, and handle data after TE is
  307. >>done with it - atoi, for example.
  308. >
  309.  
  310. The TCL for THINK C 5.0 has a spreadsheet class.  This is probably worth
  311. looking into.  It may be a bit of a stretch to put editing into each
  312. cell, but it should work.
  313.  
  314. >>Is there a good and EASY way of doing this?  I really only need a
  315. >>20x5 array of items - a little to big for a Dialog, but seems like it will
  316. >>be a pain in a window with TextEdit
  317.  
  318. Don't be afraid to go OO! (object-oriented) :)  Putting an CEditText
  319. item into each cell should handle it without much work by you.
  320.  
  321. Roger
  322. - --
  323. > Roger Allen                   |                                        <
  324. > Amdahl Computer Development   | What are you looking here for?         <
  325. > rla20@cd.amdahl.com           |                                        <
  326.  
  327. ---------------------------
  328.  
  329. From: stevenj@athena.mit.edu (Steven G Johnson)
  330. Subject: Loading Resources into MF Temp Mem.
  331. Date: 14 Jul 92 20:04:03 GMT
  332. Organization: Massachusetts Institute of Technology
  333.  
  334. Hello.  I have a large picture resource that I am using for my about
  335. box.  It takes a lot of memory, and I would rather not set the
  336. suggested size of my application to be that much larger just in order
  337. to have the about box work.  So, I was wondering:  is there any way to
  338. load a resource into MultiFinder temporary memory rather than into my
  339. application's memory?  It seems like there should be a way to do this,
  340. but I can't figure it out.
  341.  
  342. Please respond via email as I am not able to read this newsgroup very
  343. often.  I will post a summary of responses is there is interest (and
  344. if I get any responses).  Thanks in advance for any help.
  345.  
  346.                     Cordially,
  347.                     Steven G. Johnson
  348.  
  349.  
  350. - -----------------------------------------------------------------------------  
  351. I really don't understand all this business about signatures.  Mind
  352. your own business!  (Or, if you are really nosy, you can finger me.)
  353. - -----------------------------------------------------------------------------
  354.  
  355. +++++++++++++++++++++++++++
  356.  
  357. From: stevenj@athena.mit.edu (Steven G Johnson)
  358. Organization: Massachusetts Institute of Technology
  359. Date: Wed, 15 Jul 1992 17:31:35 GMT
  360.  
  361. Hello again.  I've recieved a number of responses to my request for
  362. information on reading resources into MF temporary memory, as well
  363. as some requests for a summary of responses.
  364.  
  365. The consensus seems to be that there is no safe way to do this under
  366. System 6, but under System 7 you can use the ReadPartialResource
  367. routine to do the job (after checking the appropriate Gestalt selector
  368. first, of course).
  369.  
  370. A number of people suggested reading the raw resource fork or putting
  371. the picture into the application's data fork instead, and then perhaps
  372. even modifying the QD capture procs to read it in a little bit at a
  373. times, thus obviating the necessity of having it all in memory at
  374. once.
  375.  
  376. A couple people suggested setting the zone to be in MF temp. memory,
  377. but as this is undocumented I did not think it was particularly safe
  378. to try (yes, I am weak of heart, I know).
  379.  
  380. Many thanks for all your help.  Ciao!
  381.  
  382.                         Cordially,
  383.                         Steven G. Johnson
  384.  
  385.  
  386. +++++++++++++++++++++++++++
  387.  
  388. From: jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
  389. Date: 16 Jul 92 19:57:28 GMT
  390. Organization: Computer Science Dept, QMW, University of London
  391.  
  392. In <1992Jul15.173135.13005@athena.mit.edu> stevenj@athena.mit.edu (Steven G Johnson) writes:
  393.  
  394. >Hello again.  I've recieved a number of responses to my request for
  395. >information on reading resources into MF temporary memory, as well
  396. >as some requests for a summary of responses.
  397.  
  398. >The consensus seems to be that there is no safe way to do this under
  399. >System 6, but under System 7 you can use the ReadPartialResource
  400. >routine to do the job (after checking the appropriate Gestalt selector
  401. >first, of course).
  402.  
  403. This seems awfully complicated.
  404.  
  405. >A couple people suggested setting the zone to be in MF temp. memory,
  406. >but as this is undocumented I did not think it was particularly safe
  407. >to try (yes, I am weak of heart, I know).
  408.  
  409. Well, I was one of those people. I don't think there's anything
  410. undocumented about the approach I suggested, which was:
  411.  
  412. 1. Allocate enough memory using MF temporary memory. Cop out
  413. if you can't.
  414.  
  415. 2. Make sure the memory can't move, then call _InitZone to make
  416. it a heap.
  417.  
  418. 3. Save the current zone (_GetZone), the _SetZone to your new
  419. heap.
  420.  
  421. 4. Load and use the resource(s)
  422.  
  423. 5. Release the resources, _SetZone to the old zone and dispose
  424. of the MF memory.
  425.  
  426. As I mentioned, I haven't tried this, but I have been giving it
  427. some thought recently. I can't think of any objections to this
  428. method, which will work under any system if MF is running.
  429.  
  430. Would someone better versed than I in the internals of the
  431. Memory Manager like to comment?
  432.  
  433. Jeremy
  434. >Many thanks for all your help.  Ciao!
  435.  
  436. >                                               Cordially,
  437. >                                               Steven G. Johnson
  438.  
  439. +++++++++++++++++++++++++++
  440.  
  441. From: lsr@taligent.com (Larry Rosenstein)
  442. Date: 17 Jul 92 00:51:16 GMT
  443. Organization: Taligent, Inc.
  444.  
  445. In article <1992Jul16.195728.15866@dcs.qmw.ac.uk>, jeremyr@dcs.qmw.ac.uk
  446. (Jeremy Roussak) wrote:
  447. > Well, I was one of those people. I don't think there's anything
  448. > undocumented about the approach I suggested, which was:
  449.  
  450. That should work (as long as the resource isn't marked System, of course),
  451. although you have to know how much extra to allocate for the heap zone.
  452.  
  453. You would still need to handle the case where there isn't enough temporary
  454. memory available and fall back on a simpler picture, or read the picture
  455. directly from disk.
  456.  
  457. Larry Rosenstein
  458. Taligent, Inc.
  459.  
  460. lsr@taligent.com
  461.  
  462. +++++++++++++++++++++++++++
  463.  
  464. From: dodd@apple.com (Mike Dodd)
  465. Date: Fri, 17 Jul 1992 04:41:52 GMT
  466. Organization: Apple Computer Inc.
  467.  
  468. In article <1992Jul16.195728.15866@dcs.qmw.ac.uk>, jeremyr@dcs.qmw.ac.uk (Jeremy Roussak) writes:
  469. > Well, I was one of those people. I don't think there's anything
  470. > undocumented about the approach I suggested, which was:
  471. > 1. Allocate enough memory using MF temporary memory. Cop out
  472. > if you can't.
  473. > 2. Make sure the memory can't move, then call _InitZone to make
  474. > it a heap.
  475. > 3. Save the current zone (_GetZone), the _SetZone to your new
  476. > heap.
  477. > 4. Load and use the resource(s)
  478. > 5. Release the resources, _SetZone to the old zone and dispose
  479. > of the MF memory.
  480.  
  481. i don't know what the original intent of loading resources into the 
  482. multifinder zone was, but this seems an expensive (time-wise) method.
  483. i think that setting up and shutting down zones like this is relatively
  484. time consuming...
  485.  
  486. - -Mike Dodd-
  487. Apple Computer
  488. ** What I say is my opinion. Not Apple's. **
  489.  
  490.  
  491. +++++++++++++++++++++++++++
  492.  
  493. From: keith@taligent.com (Keith Rollin)
  494. Date: 17 Jul 92 18:53:52 GMT
  495. Organization: Taligent
  496.  
  497. In article <1992Jul17.044152.12630@pcnntp.apple.com>, dodd@apple.com (Mike Dodd)
  498. writes:
  499. > i don't know what the original intent of loading resources into the 
  500. > multifinder zone was, but this seems an expensive (time-wise) method.
  501. > i think that setting up and shutting down zones like this is relatively
  502. > time consuming...
  503.  
  504. The original poster didn't have room in his application heap for a picture he
  505. wanted to render for his About Box.
  506.  
  507. Creating your own zone isn't much different (time-wise) that getting the handle
  508. for it in the first place, and is certainly _much_ less expensive than either
  509. the eventual reading of the picture from the disk or the drawing of it to a
  510. window.
  511.  
  512. - --
  513. Keith Rollin
  514. Phantom Programmer
  515. Taligent, Inc.
  516.  
  517. +++++++++++++++++++++++++++
  518.  
  519. From: jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
  520. Date: 18 Jul 92 20:12:23 GMT
  521. Organization: Computer Science Dept, QMW, University of London
  522.  
  523. In article <1992Jul17.044152.12630@pcnntp.apple.com>, dodd@apple.com (Mike Dodd)
  524. writes:
  525. >
  526. > i don't know what the original intent of loading resources into the
  527. > multifinder zone was, but this seems an expensive (time-wise) method.
  528. > i think that setting up and shutting down zones like this is relatively
  529. > time consuming...
  530.  
  531. I forget what the original poster wanted to do (something
  532. connected with a large PICT and not wanting to keep all the
  533. necessary memory for himself all the time). My reasons for
  534. giving it thought were connected with an INIT (extension) I'm
  535. writing. To configure this INIT, a large code resource is
  536. loaded and run. Since the INIT is running at the time in the
  537. partition of the current app, it doesn't know how much free
  538. memory may be available. I ran into some problems with DarkSide
  539. in particular, since it (laudably) has almost no memory free in
  540. its partition. Similarly, the system heap may well not have
  541. much memory free.
  542.  
  543. At the moment, I just put up an alert suggesting switching to
  544. another app, but it would be much better if I could load my
  545. resource into temporary memory, if it's available.
  546.  
  547. Jeremy
  548.  
  549. +++++++++++++++++++++++++++
  550.  
  551. From: scott@mcl.ucsb.edu (Scott Bronson)
  552. Date: 21 Jul 92 21:57:27 GMT
  553.  
  554. If I recall, the original reson for pulling this huge resource into a small
  555. application heap was to draw a color about box with a PICT.  If so, IM-V
  556. describes around page 90 or so how to spool a picture in from the disk.
  557. I was hoping someone who knows more about this than I would mention this,
  558. as the one time I tried to get this code to work I couldn't get it to stop
  559. crashing.  I'm fairly certain that it was my fault, but as such, I don't
  560. feel like an expert with PICT spooling.
  561.  
  562. You could probably rewrite GetPICTData to pull the opcodes in using partial
  563. resource calls, but, personally, I would just stick the PICT data into the
  564. application's data fork and spool from that using (almost?) the exact code
  565. from the book.  Very compatible, suitably fast, and it's all in IM-V page 88.
  566.  
  567.     - Scott
  568.  
  569. +++++++++++++++++++++++++++
  570.  
  571. From: Chewy@cup.portal.com (Paul Frederick Snively)
  572. Date: Wed, 22 Jul 92 22:13:40 PDT
  573. Organization: The Portal System (TM)
  574.  
  575. I have an alternative, hopefully simpler, suggestion:
  576.  
  577. Use Gestalt to determine whether temporary memory is `real memory' or not.
  578. If it is, then allocate a small (say, zero byte) temporary handle, and call
  579. HandleZone on it to get the temorary zone.  Then you can GetZone the current
  580. Zone, SetZone to the temporary zone, manage memory, and when you're done,
  581. SetZone back to the old Zone.
  582.  
  583. Incidentally, when using temporary memory, it's best to _avoid_ MoveHHi,
  584. because MultiFinder/The Process Manager allocate application space _from the
  585. top down_, so MoveHHi on temporary handles will actually tend to _cause_ heap
  586. fragmentation rather than alleviate it.  Instead, you may wish to consider
  587. using ReservMem to attempt to reserve memory, and then allocate your temporary
  588. handle.  ReservMem attempts to reserve memory as _low_ in the heap as possible
  589. (it's what NewPtr calls to do its thing).
  590.  
  591. Paul Snively
  592. Dissolute Wandering Hacker
  593. chewy@apple.com
  594.  
  595. ---------------------------
  596.  
  597. From: rohl@vax.oxford.ac.uk
  598. Subject: updating finder windows
  599. Date: 19 Jul 92 08:55:17 GMT
  600. Organization: Oxford University VAXcluster
  601.  
  602. I am writing a drag-and-drop application which will swap the case of the
  603. names of files dropped on it (because I can't get AFE to give me lower
  604. case names for files on a PC disk).  My problem is that I can't get the
  605. finder to update the name change immediately (althogh closing the folder
  606. and reopening it shows that the names have in fact been changed).  I sent
  607. this query to info-mac and got a unanimous answer - I have to change the
  608. modification data of the folder containing the files.  I believe I have
  609. done this with the following code:
  610.  
  611.             fileName = (char *) fss->name;
  612.             SwapName(swappedName, fileName);
  613.             err = FSpRename(fss, swappedName);
  614.             /* touch the home directory to update finder windows */
  615.             vParams.dirInfo.ioCompletion = nil;
  616.             vParams.dirInfo.ioVRefNum = fss->vRefNum;
  617.             vParams.dirInfo.ioFDirIndex = -1;
  618.             vParams.dirInfo.ioDrDirID = fss->parID;
  619.             vParams.dirInfo.ioNamePtr = temp;
  620.             err = PBGetCatInfo(&vParams, FALSE);
  621.             *vParams.dirInfo.ioNamePtr = 0;
  622.             GetDateTime(&vParams.dirInfo.ioDrMdDat);
  623.             err = PBSetCatInfo(&vParams, FALSE);
  624.             err = PBFlushVol(&vParams, FALSE);
  625.             
  626. This code does change the modification date of the folder (as shown by 
  627. doing a get info on the folder) but does not update the finder window
  628. containing the files.  What am I missing???
  629.  
  630.   Thanks for all help
  631.       Andrew Rohl
  632.  
  633. +++++++++++++++++++++++++++
  634.  
  635. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  636. Organization: Kalamazoo College
  637. Date: Mon, 20 Jul 1992 17:48:56 GMT
  638.  
  639. rohl@vax.oxford.ac.uk writes:
  640. >My problem is that I can't get the
  641. >finder to update the name change immediately (althogh closing the folder
  642. >and reopening it shows that the names have in fact been changed).  ...
  643. >I have to change the
  644. >modification data of the folder containing the files.  I believe I have
  645. >done this with the following code:
  646. >
  647. >[code deleted]
  648. >            
  649. >This code does change the modification date of the folder (as shown by 
  650. >doing a get info on the folder) but does not update the finder window
  651. >containing the files.  What am I missing???
  652.  
  653. I think you want to update the date of the file's directory's parent,
  654. rather than the directory itself.  I'm not too bright when it comes
  655. to the File Manager, so I could be wrong;  still, it looks like no one
  656. else is going to answer this question.  Anyway, here's the code I use
  657. (I stole it):
  658.  
  659.  
  660.     /* Straight from Jon Waette's personal library.  I made a few
  661.      * minor changes.
  662.      */
  663. void touchDir(short vol, long dir)
  664. {
  665.     CInfoPBRec info;
  666.     Str63 name;
  667.     
  668.     clearMemory(&info, sizeof(info)); // Play it safe
  669.     
  670.     info.dirInfo.ioDrDirID = dir;
  671.     info.dirInfo.ioVRefNum = vol;
  672.     info.dirInfo.ioNamePtr = name;
  673.     info.dirInfo.ioFDirIndex = -1;
  674.     
  675.     FailOSErr(PBGetCatInfo(&info, FALSE)); // Get the info on the folder
  676.     
  677.     info.dirInfo.ioCompletion = 0;
  678.     info.dirInfo.ioDrDirID = info.dirInfo.ioDrParID;
  679.     info.dirInfo.ioFDirIndex = 0;
  680.     GetDateTime(&info.dirInfo.ioDrMdDat);
  681.     
  682.     FailOSErr(PBSetCatInfo(&info, FALSE)); // Set the modified time
  683. }
  684. - -- 
  685.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  686.  I suppose ya don't think I was run over by a streetcar!
  687.  
  688. +++++++++++++++++++++++++++
  689.  
  690. From: Tommy.Brown@f204.n2603.z1.ieee.org (Tommy Brown)
  691. Organization: FidoNet node 1:2603/204 - Not Even Odd, Forest Hills NY
  692. Date: Mon, 20 Jul 1992 22:05:00 GMT
  693.  
  694. I don't think that you CAN get the Finder to update the window immediately,
  695.  
  696. because as far as I know, the Finder just doesn't constantly poll the disk to
  697. see if anything's been changed. The only thing I can think of is if you were
  698.  
  699. somehow able to get a WindowPtr to the window that the file's in. Then you
  700.  
  701. could call InvalRect, either over the whole window or just the rectangle of
  702.  
  703. the icon which you want to change, which I believe you can get by calling
  704.  
  705. GetFInfo. How to get a WindowPtr to the correct window, though, I don't know. 
  706.  
  707. - --  
  708. =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
  709.  Tommy Brown - Internet: Tommy.Brown@f204.n2603.z1.ieee.org
  710.  
  711. +++++++++++++++++++++++++++
  712.  
  713. From: ewylie@ocf.berkeley.edu (Elizabeth Wylie)
  714. Date: 22 Jul 1992 20:33:23 GMT
  715. Organization: U. C. Berkeley Open Computing Facility
  716.  
  717. In article <15246.2A6C9813@zeus.ieee.org> Tommy.Brown@f204.n2603.z1.ieee.org (Tommy Brown) writes:
  718. >I don't think that you CAN get the Finder to update the window immediately,
  719. >
  720. >because as far as I know, the Finder just doesn't constantly poll the disk to
  721. >see if anything's been changed. The only thing I can think of is if you were
  722. >
  723.  
  724. You'd be surprised what the finder does.  Put a trap break on HFSDispatch sometime.  You'll be surprised.  The finder is constantly cycling through open windows and getting folder dates etc.
  725.  
  726. If you want to force the window to update, change the modification date of the folder containing the item you changed.
  727.  
  728. The finder always updates for me.  Sometime soon I may be posting a small INIT that does this as well as patch a few traps.  The INIT automatically relocates items dropped in a folder.
  729.  
  730. Just to a PBGetCatInfo followed by a PBSetCatInfo.  But remember that the ioDirID field (and a few others, I think) get chewed after the call is complete.
  731.  
  732. - -E Wylie
  733.  
  734. and 
  735.  
  736.  
  737. ---------------------------
  738.  
  739. From: ez008347@fred.ucdavis.edu
  740. Subject: HOW IS QUICKBASIC FOR THE MAC?
  741. Date: 20 Jul 92 23:08:39 GMT
  742. Organization: Computing Services, UC Davis
  743.  
  744. I have a compiled PC program I wrote in QuickBasic.  I want to get one done for
  745. the Mac.  Questions:
  746. 1) How is QuickBasic for the Mac? Please only answer this one if you know what 
  747.    you are talking about.
  748. 2) What applications generators do you recommend? (Anyone can answer this.)
  749.   
  750. The program is not database oriented.  It is a questionnaire whose answers are
  751.  
  752. +++++++++++++++++++++++++++
  753.  
  754. From: cormacks@garnet.berkeley.edu
  755. Date: 21 Jul 92 04:08:22 GMT
  756. Organization: University of California, Berkeley
  757.  
  758. I don't know if you deem me worthy to respond, but I 
  759. programmed in QuickBasic on the mac for about 4
  760. years.  For simple stuff, it's VERY easy to use; 
  761. development time is almost zero.  For math-intensive
  762. stuff (convolutions, etc.), Think C compiled code
  763. runs some 5 times faster that QuickBasic compiled
  764. code.  Also, it is my understanding (from Microsoft
  765. support) that Microsoft has basically abandoned the
  766. product.  Hope this helps.
  767. - -- 
  768. - ------------------------------------------------------------------
  769. Larry Cormack         *  When exploring the unknown, by definition
  770. Physiological Optics  *  you do not know what you will find.
  771. U. C. Berkeley        *        *     *     *     *     *     *     *
  772.  
  773. +++++++++++++++++++++++++++
  774.  
  775. From: ccmlh@buitc.bu.edu (Mark Hayes)
  776. Date: 21 Jul 92 05:04:37 GMT
  777. Organization: Boston University, Boston, MA, USA
  778.  
  779. In article <14g2jmINNkds@agate.berkeley.edu> cormacks@garnet.berkeley.edu writes:
  780. >  Also, it is my understanding (from Microsoft
  781. >support) that Microsoft has basically abandoned the
  782. >product.  Hope this helps.
  783.  
  784. For what this is worth, I just received an updated version of
  785. QuickBasic from Microsoft as a result of having requested that I
  786. be put on an upgrade-requestors list over a year ago. The new
  787. version is supposedly System 7 compatible, though it doesn't
  788. let you do anything particularly "System 7 lustful".
  789.  
  790.  
  791.  
  792. +++++++++++++++++++++++++++
  793.  
  794. From: fbaker@nyx.cs.du.edu (fred baker)
  795. Date: 21 Jul 92 05:29:58 GMT
  796. Organization: Nyx, Public Access Unix at U. of Denver Math/CS dept.
  797.  
  798. In article <15353@ucdavis.ucdavis.edu> ez008347@fred.ucdavis.edu writes:
  799. >I have a compiled PC program I wrote in QuickBasic.  I want to get one done for
  800. >the Mac.  Questions:
  801. >1) How is QuickBasic for the Mac? Please only answer this one if you know what 
  802. >   you are talking about.
  803. >2) What applications generators do you recommend? (Anyone can answer this.)
  804. >  
  805. >The program is not database oriented.  It is a questionnaire whose answers are
  806.  
  807. Run, do not walk away from MS QuickBASIC.  The last time it was updated was in
  808. 1988.  It is not 32-bit compatible, does not produce 32-bit compatible
  809. software, supports nothing more than the old eight-color QuickDraw model, and
  810. what is more, *still* costs as much as it did in 1988.  How's that for a
  811. run-on sentence?
  812.  
  813. Unfortunately, you're not going to do much better elsewhere.  The last I've
  814. heard, Zedcor still hasn't updated its ZBasic product (although it was leaps
  815. and bounds better than MS QuickBASIC), and as for True Basic, my only
  816. experience was with the demo, and it wouldn't run under System 7.  Oh yeah;
  817. MS QuickBASIC doesn't work too well with System 7 either.
  818.  
  819. Would you like to buy my copy, *real* cheap? :)
  820.  
  821. Fred
  822.  
  823. +++++++++++++++++++++++++++
  824.  
  825. From: rgonzal@gandalf.rutgers.edu (Ralph Gonzalez)
  826. Date: 22 Jul 92 19:05:42 GMT
  827. Organization: Rutgers Univ., New Brunswick, N.J.
  828.  
  829. ccmlh@buitc.bu.edu (Mark Hayes) writes:
  830.  
  831. >For what this is worth, I just received an updated version of
  832. >QuickBasic from Microsoft as a result of having requested that I
  833. >be put on an upgrade-requestors list over a year ago. The new
  834. >version is supposedly System 7 compatible, though it doesn't
  835. >let you do anything particularly "System 7 lustful".
  836.  
  837. I got my name on this list, too, but despite periodical calls to
  838. Microsoft I haven't gotten any upgrade info.
  839.  
  840. To the original poster, note that Mac QuickBASIC lacks a few of the
  841. PC versions features, such as data structures(!) -- I wonder if the
  842. update has this?  On the other hand, it offers an easy approach to
  843. writing Mac programs without using the Toolbox directly (though you'll
  844. have to do some tricky and frustrating programming to get all the
  845. details of the Mac interface working properly).  To just port a PC
  846. program should be pretty easy, though.
  847.  
  848. - -Ralph
  849. - -- 
  850. Ralph Gonzalez, Computer Science, Rutgers Univ., Camden, NJ
  851. Phone: (609) 757-6122; Internet: rgonzal@elbereth.rutgers.edu
  852. - --
  853.  
  854. +++++++++++++++++++++++++++
  855.  
  856. From: mxmora@unix.SRI.COM (Matt Mora)
  857. Date: 22 Jul 92 18:46:13 GMT
  858. Organization: SRI International, Menlo Park, California
  859.  
  860. In article <91457@bu.edu> ccmlh@buitc.bu.edu (Mark Hayes) writes:
  861. >In article <14g2jmINNkds@agate.berkeley.edu> cormacks@garnet.berkeley.edu writes:
  862.  
  863.  
  864. >For what this is worth, I just received an updated version of
  865. >QuickBasic from Microsoft as a result of having requested that I
  866. >be put on an upgrade-requestors list over a year ago. The new
  867. >version is supposedly System 7 compatible, though it doesn't
  868. >let you do anything particularly "System 7 lustful".
  869.  
  870. I just received my copy today. It cost $10.00 to upgrade.
  871. I hear that it fixes a few bugs but causes one new one.
  872. I have released some pure code resources that lets quickbasic 
  873. do some cool stuff. Look for it at the archive sites.
  874.  
  875.  
  876.  
  877. Matt
  878.  
  879.  
  880.  
  881.  
  882.  
  883. - -- 
  884. ___________________________________________________________
  885. Matthew Mora                |   my Mac  Matt_Mora@sri.com
  886. SRI International           |  my unix  mxmora@unix.sri.com
  887. ___________________________________________________________
  888.  
  889. +++++++++++++++++++++++++++
  890.  
  891. From: mxmora@unix.SRI.COM (Matt Mora)
  892. Date: 22 Jul 92 18:50:56 GMT
  893. Organization: SRI International, Menlo Park, California
  894.  
  895. In article <15353@ucdavis.ucdavis.edu> ez008347@fred.ucdavis.edu writes:
  896.  
  897. >1) How is QuickBasic for the Mac? Please only answer this one if you know what
  898.  
  899. It basically dead right now. Though microsoft has releaseda version of it 
  900. that works with system seven finally. 
  901.  
  902.  
  903.  
  904.  
  905. Matt
  906. - -- 
  907. ___________________________________________________________
  908. Matthew Mora                |   my Mac  Matt_Mora@sri.com
  909. SRI International           |  my unix  mxmora@unix.sri.com
  910. ___________________________________________________________
  911.  
  912. ---------------------------
  913.  
  914. From: kent@sunfs3.Camex.COM (Kent Borg)
  915. Subject: Ah, but I am clever in how I patch, no?
  916. Organization: Camex Inc., Boston MA
  917. Date: Mon, 13 Jul 1992 23:26:32 EDT
  918.  
  919.  
  920. So MacDTS says I am right to worry that I am possibly doing Bad Stuff,
  921. but they didn't say why.  They drive me to ask the folks who know.
  922. You.
  923.  
  924. I am patching _GetResource in a "double-dip" technique.  I watch for a
  925. magic combination of resource ID and type.  When I spot it I call the
  926. address I originally found for _GetResource, tamper with the results
  927. in the form of appending some clever stuff to the end of the resource,
  928. but then leave it in the heap and resource map (but, I hope, in such a
  929. way as to not have it get written back out in my tampered state), and
  930. finally jump to the original _GetResource address to let it find my
  931. version of the PREC 103 (yes, I admit it, I am playing with printing
  932. stuff).
  933.  
  934. The queston: Will my jumping to the original address keep any
  935. come-from patches happy (and under system 7 maybe this is no problem)?
  936. Does it absolve me the sins of having called the original address?
  937.  
  938. Thanks.
  939.  
  940.  
  941. P.S.  Please post any responses, BUT if you have something really
  942. useful to say, please cc: me by mail.  Our news feed seems to be
  943. nearly two weeks late on the inbound and I would like to get any
  944. clever answers sooner than that.  (If you want to send mail to
  945. "sa@camex.com" and tell the System Administration types that this is
  946. important enough to fix, I wouldn't complain...)
  947.  
  948. - --
  949. Kent Borg                                   kent@camex.com or kentborg@aol.com
  950.                                             H:(617) 776-6899  W:(617) 426-3577
  951. As always, things look better when some costs are left out.
  952.                               -Economist 3-28-92 p. 94
  953.  
  954. +++++++++++++++++++++++++++
  955.  
  956. From: Michael_Hecht@mac.sas.com (Michael Hecht)
  957. Date: 14 Jul 92 14:47:31 GMT
  958. Organization: SAS Institute Inc.
  959.  
  960. In article <1992Jul13.232632.7427@sunfs3.Camex.COM>, kent@sunfs3.Camex.COM
  961. (Kent Borg) describes a "double-dip" technique for legally tail-patching
  962. GetResource.
  963.  
  964. A perhaps legal tail-patching method that I thought up once was this:
  965.  
  966. patch_code:
  967.    unpatch myself from _GetResource
  968.    call _GetResource with my arguments
  969.    repatch myself into _GetResource
  970.  
  971.    play around with the results
  972.    return
  973.  
  974. patch_installer:
  975.    patch patch_code into _GetResource
  976.  
  977. It would seem that this would satisfy the requirements of any come-from
  978. patch to _GetResource, since it would appear to them that they come from
  979. the invocation within my patch code.
  980.  
  981. Comments?
  982.  
  983. - --Michael
  984.  
  985. =======================================================================
  986. Michael P. Hecht                 | Internet:  Michael_Hecht@mac.sas.com
  987. SAS Institute Inc.; Cary, NC USA | AppleLink: SAS.HECHT
  988.  
  989. +++++++++++++++++++++++++++
  990.  
  991. From: creiman@Apple.COM (Charlie Reiman)
  992. Date: 14 Jul 92 17:56:11 GMT
  993. Organization: Apple Computer Inc., Cupertino, CA
  994.  
  995. Michael_Hecht@mac.sas.com (Michael Hecht) writes:
  996.  
  997. >In article <1992Jul13.232632.7427@sunfs3.Camex.COM>, kent@sunfs3.Camex.COM
  998. >(Kent Borg) describes a "double-dip" technique for legally tail-patching
  999. >GetResource.
  1000.  
  1001. >A perhaps legal tail-patching method that I thought up once was this:
  1002.  
  1003. >patch_code:
  1004. >   unpatch myself from _GetResource
  1005. >   call _GetResource with my arguments
  1006. >   repatch myself into _GetResource
  1007.  
  1008. >   play around with the results
  1009. >   return
  1010.  
  1011. >patch_installer:
  1012. >   patch patch_code into _GetResource
  1013.  
  1014. I'm not commenting on the wisdom of such a ploy to avoid tail patches,
  1015. however, I would strongly suggest you make your code "re-entrant proof",
  1016. rather than skanking around with _get/_setTrapAddress.
  1017.  
  1018. Your patch probably has some static storage in memory. Make one word of
  1019. it an "inUse" flag. When you enter your patch, check the flag. If it is
  1020. set, simply call the original trap. If it is clear, set it and proceed
  1021. to do your evil mucking around. When your are finished mucking around,
  1022. clear the flag and exit as you normally would (by jumping to the
  1023. original code).
  1024.  
  1025. So what does this buy you? Simple: You can invoke the patch you are
  1026. trapping from within your patch without needing to change the trap
  1027. address.
  1028.  
  1029. I use this technique in a large, very skanky hack to prevent my patches
  1030. from colliding with my interrupt routines when the are saving and
  1031. restoring A5.
  1032.  
  1033. FYI: Tail patches are a bad thing. I suggest checking out the
  1034. TechNotes. 
  1035. - -- 
  1036. Charlie Reiman - Speaking as an individual, not for Apple Computer.
  1037. creiman@apple.com
  1038.  
  1039. +++++++++++++++++++++++++++
  1040.  
  1041. From: keith@taligent.com (Keith Rollin)
  1042. Date: 14 Jul 92 18:10:30 GMT
  1043. Organization: Taligent
  1044.  
  1045. In article <Michael_Hecht-140792104501@studly.mac.sas.com>,
  1046. Michael_Hecht@mac.sas.com (Michael Hecht) writes:
  1047. > A perhaps legal tail-patching method that I thought up once was this:
  1048. > patch_code:
  1049. >    unpatch myself from _GetResource
  1050. >    call _GetResource with my arguments
  1051. >    repatch myself into _GetResource
  1052. >    play around with the results
  1053. >    return
  1054. > patch_installer:
  1055. >    patch patch_code into _GetResource
  1056. > It would seem that this would satisfy the requirements of any come-from
  1057. > patch to _GetResource, since it would appear to them that they come from
  1058. > the invocation within my patch code.
  1059.  
  1060. Your method doesn't solve the problem of tail-patching.
  1061.  
  1062. Come from patches determine when they should kick in by looking at the return
  1063. address on the stack. Either way you do it (jumping directly to the saved
  1064. original address or putting the original address back into the trap table), the
  1065. return address is still going to point back to your patch.
  1066.  
  1067. By the way, removing your patch from the trap table is tricky business. You have
  1068. to take into account the possibility that someone has applied a patch over
  1069. yours. If that has occured, there is no way for you to remove your patch (at
  1070. least, not without affecting the uber-patch).
  1071.  
  1072. - --
  1073. Keith Rollin
  1074. Phantom Programmer
  1075. Taligent, Inc.
  1076.  
  1077.  
  1078. +++++++++++++++++++++++++++
  1079.  
  1080. From: wombat@claris.com (Scott Lindsey)
  1081. Date: 14 Jul 92 22:18:14 GMT
  1082. Organization: Claris Corporation, Vancouver WA
  1083.  
  1084. In article <Michael_Hecht-140792104501@studly.mac.sas.com>, Michael_Hecht@mac.sas.com (Michael Hecht) writes:
  1085. > In article <1992Jul13.232632.7427@sunfs3.Camex.COM>, kent@sunfs3.Camex.COM
  1086. > (Kent Borg) describes a "double-dip" technique for legally tail-patching
  1087. > GetResource.
  1088. > A perhaps legal tail-patching method that I thought up once was this:
  1089. > patch_code:
  1090. >    unpatch myself from _GetResource
  1091. >    call _GetResource with my arguments
  1092. >    repatch myself into _GetResource
  1093. >    play around with the results
  1094. >    return
  1095. > patch_installer:
  1096. >    patch patch_code into _GetResource
  1097. > It would seem that this would satisfy the requirements of any come-from
  1098. > patch to _GetResource, since it would appear to them that they come from
  1099. > the invocation within my patch code.
  1100.       ^^^^^^^^^^ ^^^^^^ ^^ ^^^^^ ^^^^
  1101. .. and not from the original caller, which is what Apple's tail-patch-
  1102. sensitive code would be looking for.  The whole problem of tail patches is the
  1103. return address that's on the stack.  In some of Apple's patches, they
  1104. check this for (in general) certain ROM addresses.  If it's your address on
  1105. the stack instead, Apple's patch won't work.
  1106.  
  1107.  
  1108. - --
  1109. Scott Lindsey <wombat@claris.com>
  1110.  
  1111. +++++++++++++++++++++++++++
  1112.  
  1113. From: gurgle@netcom.com (Pete Gontier)
  1114. Date: Wed, 15 Jul 92 07:58:34 GMT
  1115. Organization: cellular
  1116.  
  1117. kent@sunfs3.Camex.COM (Kent Borg) writes:
  1118.  
  1119.  
  1120. >So MacDTS says I am right to worry that I am possibly doing Bad Stuff,
  1121. >but they didn't say why.  They drive me to ask the folks who know.
  1122. >You.
  1123.  
  1124. DTS just says these things on general principle. If you mess with the
  1125. fundamental operation of the machine, which is what you're doing when
  1126. you do a hack against the trap mechanism, which is essentially what
  1127. you're doing, it may or may not preclude Apple from doing some other
  1128. hack, which may or may not include the same sort of thing as your hack.
  1129.  
  1130. >I am patching _GetResource in a "double-dip" technique.  I watch for a
  1131. >magic combination of resource ID and type.  When I spot it I call the
  1132. >address I originally found for _GetResource, tamper with the results
  1133. >in the form of appending some clever stuff to the end of the resource,
  1134. >but then leave it in the heap and resource map (but, I hope, in such a
  1135. >way as to not have it get written back out in my tampered state), and
  1136. >finally jump to the original _GetResource address to let it find my
  1137. >version of the PREC 103 (yes, I admit it, I am playing with printing
  1138. >stuff).
  1139.  
  1140. Steve Brecher revealed in a developer's panel talk at a recent MacWorld
  1141. that this is one of the tricky things Suitcase does. You are free to
  1142. interpret this info as you will. :-)
  1143.  
  1144. >The queston: Will my jumping to the original address keep any
  1145. >come-from patches happy (and under system 7 maybe this is no problem)?
  1146. >Does it absolve me the sins of having called the original address?
  1147.  
  1148. Your jumping absolves you. The only thing you have to worry about is
  1149. what address is on the top of the stack. That's the return address
  1150. that got pushed there when _GetResource set off the A-trap mechanism,
  1151. and that's what a come-from patch is all about. In this case, if it
  1152. ran and returned control to the caller of _GetResource, that would
  1153. make *me personally* pretty confident that I had done it right.
  1154. - -- 
  1155.  Pete Gontier // EC Technology // gurgle@netcom.com
  1156.  
  1157. +++++++++++++++++++++++++++
  1158.  
  1159. From: peterc@cubetech.com (Peter Creath)
  1160. Date: 15 Jul 92 03:09:03 GMT
  1161. Organization: Cube Technologies
  1162.  
  1163.  
  1164. In article <70008@apple.Apple.COM> (comp.sys.mac.programmer), creiman@Apple.COM (Charlie Reiman) writes:
  1165. > Michael_Hecht@mac.sas.com (Michael Hecht) writes:
  1166. > >In article <1992Jul13.232632.7427@sunfs3.Camex.COM>, kent@sunfs3.Camex.COM
  1167. > >(Kent Borg) describes a "double-dip" technique for legally tail-patching
  1168. > >GetResource.
  1169. > >A perhaps legal tail-patching method that I thought up once was this:
  1170. > >patch_code:
  1171. > >   unpatch myself from _GetResource
  1172. > >   call _GetResource with my arguments
  1173. > >   repatch myself into _GetResource
  1174. > >   play around with the results
  1175. > >   return
  1176. > >patch_installer:
  1177. > >   patch patch_code into _GetResource
  1178.  
  1179. No no no.  Well, maybe.  If this is only for your app, in which case
  1180. you shouldn't even be patching.  So no.  What you do instead is:
  1181.  
  1182. At startup, your INIT takes the trap address (GetTrapAddress) and
  1183. stores it somewhere in your snippet of code to be installed as the
  1184. patch.  Patch the trap to your new snippet of code.  Your snippet
  1185. of code JSR's the address your INIT picked out for you.  Sounds complex,
  1186. but it's not too difficult.  Pre-patching and tail-patching aren't
  1187. too bad, just make sure you save off and restore all the registers
  1188. you use, just in case...
  1189.  
  1190. - ----------------------------------------------------------------------------
  1191. Peter Creath                 "When I was a boy I was told that anybody could
  1192. peterc@cubetech.com           become president; I'm beginning to believe it."
  1193.                                                            -- Clarence Darrow
  1194.  
  1195. +++++++++++++++++++++++++++
  1196.  
  1197. From: dplatt@ntg.com (Dave Platt)
  1198. Date: 17 Jul 92 17:59:23 GMT
  1199. Organization: New Technologies Group, Inc.  Palo Alto CA
  1200.  
  1201. In article <dx3uv972.8i07vs@moebius.cubetech.com> peterc@cubetech.com writes:
  1202.  
  1203. >At startup, your INIT takes the trap address (GetTrapAddress) and
  1204. >stores it somewhere in your snippet of code to be installed as the
  1205. >patch.  Patch the trap to your new snippet of code.  Your snippet
  1206. >of code JSR's the address your INIT picked out for you.  Sounds complex,
  1207. >but it's not too difficult.  Pre-patching and tail-patching aren't
  1208. >too bad, just make sure you save off and restore all the registers
  1209. >you use, just in case...
  1210.  
  1211. AAAAAAAaaaaaaaaaaaaagggggggggggggggghhhhhhhhhhhhh.
  1212.  
  1213. Pardon.  Hit a nerve there.  Calm down, Dave.  Don't shout so mucj.
  1214.  
  1215. Apple has recommended, for YEARS, that programmers avoid tail patching
  1216. like the plague.  Don't do it.  Ever.  Period.  If you must patch a
  1217. trap, use a head-patch only - exit by JMP'ing to the original trap
  1218. handler.
  1219.  
  1220. If you tail-patch a trap, then the trap code can't tell where it was
  1221. originally called from.  This is a Bad Situation.
  1222.  
  1223. The reason:  some of Apple's own bug-fix patches work by installing a
  1224. head patch into a trap.  The patch checks the return-address to see
  1225. whether it matches a specific address in the ROM;  if so, the patch does
  1226. something special (usually to fix a bug which exists in the code which
  1227. called the trap, NOT in the trap itself).
  1228.  
  1229. It's a odd technique, but there's a good reason for it - it permits
  1230. Apple to install a small head-patch to a trap, rather than having to
  1231. patch out the entire guts of what may be a fairly large routine or
  1232. manager in the ROM.  Much less RAM is used this way.
  1233.  
  1234. If you install a tail-patch on a trap, and if it turns out to be a patch
  1235. that Apple has used in this way, YOUR TAIL PATCH WILL DISABLE APPLE'S
  1236. BUG FIX.  Your INIT-installed patch may cause old bugs to reappear, or
  1237. cause crashes or other unexpected behavior, under some System versions,
  1238. on some hardware configurations, but perhaps not on others.
  1239.  
  1240. This can happen even if your patch is, itself, completely perfect and
  1241. blameless (except for the fact that it's a tail patch).
  1242.  
  1243. Please DO NOT USE TAIL PATCHES.  They are a useful, obvious technique,
  1244. which has been declared off-limits.  It's a shame, but that's how it
  1245. goes.
  1246.  
  1247. Sorry, I'm shouting again... I'll go have a cola and cool down a bit.
  1248.  
  1249. - -- 
  1250. Dave Platt                                                VOICE: (415) 813-8917
  1251.               Domain: dplatt@ntg.com      UUCP: ...netcomsv!ntg!dplatt
  1252.  USNAIL: New Technologies Group Inc. 2468 Embarcardero Way, Palo Alto CA 94303
  1253.  
  1254. +++++++++++++++++++++++++++
  1255.  
  1256. From: scott@mcl.ucsb.edu (Scott Bronson)
  1257. Date: 20 Jul 92 05:45:39 GMT
  1258.  
  1259. In <1992Jul17.175923.9803@ntg.com> dplatt@ntg.com (Dave Platt) writes:
  1260.  
  1261. >In article <dx3uv972.8i07vs@moebius.cubetech.com> peterc@cubetech.com writes:
  1262.  
  1263.  
  1264. >Apple has recommended, for YEARS, that programmers avoid tail patching
  1265. >like the plague.  Don't do it.  Ever.  Period.  If you must patch a
  1266. >trap, use a head-patch only - exit by JMP'ing to the original trap
  1267. >handler.
  1268.  
  1269. You can chill if you're running System 7.  It uses a cool patching
  1270. technique where your patches are kept apart from the system's, so
  1271. tail patching is perfectly kosher.  Just be prepared to have your
  1272. patch ignored by the system--it'll simply forget about your patch
  1273. if it wants to.  (this is oversimplified and please get better info
  1274. on this before relying on this.)
  1275.  
  1276.     - Scott
  1277.  
  1278. +++++++++++++++++++++++++++
  1279.  
  1280. From: Quinn <quinn@cs.uwa.edu.au>
  1281. Organization: The University of Western Australia
  1282. Date: Tue, 21 Jul 1992 02:21:05 GMT
  1283.  
  1284. Scott Bronson talks about System 7's new trap patching mechanism...
  1285.  
  1286. >(this is oversimplified and please get better info
  1287. >on this before relying on this.)
  1288.  
  1289. Oh and where would you suggest we get this better info?  I've read
  1290. everything I can lay my hands on about System 7 (all the way back
  1291. to the Alpha release notes) and the first I heard about the new
  1292. patch mechanism was here in c.s.m.p.  But perhaps I missed something.
  1293.  
  1294. [Switch to Yorkshire accent]
  1295.  
  1296. Ya know when ay was a laad wee had IM I-III and eet told us all sorts
  1297. ov uuseful informaytion about the internals of the Mac but we 'ad ta
  1298. werk out tha deetails arselves.  Now da younguns 'ave IM VI and eet
  1299. gives 'em lots of pretty ecsamples but they donn't get any off da
  1300. goodies.
  1301.  
  1302. [Switch back to sanity]
  1303.  
  1304. Quinn "The Eskimo!"   <quinn@cs.uwa.edu.au>  "Real Coke, Diet .sig"
  1305. Department of Computer Science, The University of Western Australia
  1306.   -- Bewildered!  Confused!  Situation normal!
  1307.  
  1308. +++++++++++++++++++++++++++
  1309.  
  1310. From: gurgle@netcom.com (Pete Gontier)
  1311. Date: Thu, 23 Jul 92 07:18:49 GMT
  1312. Organization: cellular
  1313.  
  1314. quinn@cs.uwa.edu.au (Quinn) writes:
  1315. > I've read
  1316. > everything I can lay my hands on about System 7 (all the way back
  1317. > to the Alpha release notes) and the first I heard about the new
  1318. > patch mechanism was here in c.s.m.p.  But perhaps I missed something.
  1319.  
  1320. Now if I could only explain the utility of UseNet to my boss in terms
  1321. as simple as these, our company would probably have a full time
  1322. internet connection within a week! Unfortunately, bossy doesn't know
  1323. anything about patching.
  1324.  
  1325. More to the point, if you're worried about the legitimacy of this
  1326. information, I've heard it from at least two core members of the System 7
  1327. team (Blue Meanies), Dean Yu and Greg Marriott. Dean's on the net all
  1328. the time, and Greg is sometimes here, as well, although I am familiar
  1329. with him mostly through America Online.
  1330.  
  1331. Anyway, Dean actually can narrow it down to one trap you shouldn't tail
  1332. patch because you'll screw up a come-from patch Apple couldn't remove in
  1333. the newly-standard way. I'm not sure, but if I were up against a wall
  1334. on the wrong side of a firing squad, I'd probably guess it's FrontWindow.
  1335. - -- 
  1336.  Pete Gontier // EC Technology // gurgle@netcom.com
  1337.  
  1338. +++++++++++++++++++++++++++
  1339.  
  1340. From: keith@taligent.com (Keith Rollin)
  1341. Date: 23 Jul 92 18:55:29 GMT
  1342. Organization: Taligent
  1343.  
  1344. In article <yhgm+-c.gurgle@netcom.com>, gurgle@netcom.com (Pete Gontier) writes:
  1345. > Anyway, Dean actually can narrow it down to one trap you shouldn't tail
  1346. > patch because you'll screw up a come-from patch Apple couldn't remove in
  1347. > the newly-standard way. I'm not sure, but if I were up against a wall
  1348. > on the wrong side of a firing squad, I'd probably guess it's FrontWindow.
  1349.  
  1350. You know, I thought this was the case, too, based on my memory of something Dean
  1351. posted once. However, I recently looked into FrontWindow to see what the deal
  1352. was, and didn't see anything out of the ordinary. The only thing I saw was that
  1353. FrontWindow was one of those totally replaced traps. In other words, it gets
  1354. patched out after INIT time and doesn't chain to the original trap. So it seems
  1355. to me that FrontWindow isn't any more special than any of those trap patches
  1356. that totally replace the system trap after INIT time.
  1357.  
  1358. Looks like it's doing some layer manager sifting before returning the front
  1359. window, but that's just a guess.
  1360.  
  1361. - --
  1362. Keith Rollin
  1363. Phantom Programmer
  1364. Taligent, Inc.
  1365.  
  1366. ---------------------------
  1367.  
  1368. End of C.S.M.P. Digest
  1369. **********************
  1370.